﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using Microsoft.ReportingServices.Interfaces;
using OpenSoftStore.BusinessLogic.Bill;
using OpenSoftStore.BusinessLogic.Member;

namespace OpenSoftStore.Client.UIL.ManagePrinter
{
    public partial class DinnerPrintWindow : Form
    {
        private static DinnerPrintWindow instance;
        public DinnerSaleLogic LgcDinnerSale;

        public Boolean Drog = false;
        public int Top = 0;
        public int Left = 0;

        public static DinnerPrintWindow Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new DinnerPrintWindow();
                }
                return instance;
            }
        }

        public DinnerPrintWindow()
        {
            InitializeComponent();
            LgcDinnerSale = new DinnerSaleLogic();
        }

        private void PrintWindow_Load(object sender, EventArgs e)
        {
        }

        public void SetReport(string id)
        {
            var data = LgcDinnerSale.GetDinnerPrint(" where T_DinnerSale.Id ='" + id + "'");
            var rds = new ReportDataSource("DataSet1", data);
            rvPrint.LocalReport.DataSources.Clear();
            rvPrint.LocalReport.DataSources.Add(rds);
            rvPrint.RefreshReport();
            rvPrint.SetDisplayMode(DisplayMode.PrintLayout);
        }

        private void pbClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void PnlInfoTitle_MouseDown(object sender, MouseEventArgs e)
        {
            Drog = true;
            Top = e.Y;
            Left = e.X;
        }

        private void PnlInfoTitle_MouseMove(object sender, MouseEventArgs e)
        {
            if (!Drog) return;
            var findForm = FindForm();
            if (findForm == null) return;
            findForm.Top += e.Y - Top;
            findForm.Left += e.X - Left;
        }

        private void PnlInfoTitle_MouseUp(object sender, MouseEventArgs e)
        {
            Drog = false;
        }
    }
}
